import React, { Component } from 'react';
import { router } from 'umi';
import ProDetail from '@/pages/components/Problem/ProblemPage/ProDetail';
import ModifySalary from './ProDetail';

class Proble extends Component {
  constructor(props) {
    super(props);
    this.state = {
      modalShow: false, // 修改收入弹框显隐
      dataSource: {}, // 修改收入回显的数据
    };
  }

  onModifyData = data => {
    this.setState({
      modalShow: true,
      dataSource: data,
    });
  };

  onViewDetails = data => {
    router.push(`/salarymanage/protection/maintaindetail?wageOrderInfoId=${data.busiId}`);
  };

  // 关闭修改收入弹框
  handleModalVisible = () => {
    this.setState({
      modalShow: false,
    });
  };

  // 提交
  submitModalData = () => {
    this.setState({
      modalShow: false,
    });
  };

  render() {
    const { modalShow, dataSource } = this.state;
    return (
      <div>
        <ProDetail onModifyData={this.onModifyData} onViewDetails={this.onViewDetails} />
        {modalShow && (
          <ModifySalary
            modalShow={modalShow}
            handleModalVisible={this.handleModalVisible}
            submitModalData={this.submitModalData}
            dataSource={dataSource}
          />
        )}
      </div>
    );
  }
}

export default Proble;
